<template>
	<view class="p-0-30 bg-white">
		<view style="width: 100%;height: 4em;"></view>
		
		<view style="width:95%;height:3em;border: 1px solid #dbdbdb;border-radius: 0.3em;">
			
			<view style="width: 95%;margin: 0 auto;">
				
				<view style="width: 2em;height: 2em;position: relative;top:0.5em;float: left;">
					<image src="/static/souusod.png"/>
					
				</view>
				
				<view style="width:65%;float: left;position: relative;left: 1em;top:0.7em">
					<input @input="onKeyInput"  type="text" style="color: #c0c0c0;font-size: 1em;" v-model="sousuondie"  placeholder="请输入搜素内容"/></view>
				<view style="float: right;width:5em;height: 2em;line-height: 2em;background-color: cornflowerblue;color: #fff;text-align: center;position: relative;top:0.5em;border-radius: 0.5em;" @click="sousadje">搜素</view>
			</view>
			
		</view>
		<!--列表2-->
		<view class="d-b-c border-b p-30-0" v-for="(item, index) in tableData" :key="index">
			<view class="d-s-s f-w d-c flex-1">
				<text class="30" style="color:#c0c0c0">单号:{{ item.orderdingdan }}</text>
				<text class="30" style="color:darkorange">卡号:{{ item.jukazhanghao }}</text>
				<text class="30" style="color:darkorange">卡密:{{ item.jukamima }}</text>
				<view class="pt10 gray9 f22" >{{countDownddedd(item.time)}}</view>
			</view>
			<view class="red" v-if="item.money > 0">
			<view  style="font-size: 0.7em;text-align: right;"  class="red" v-if="item.c_money > 0">卡密面值：{{ item.c_money }}元</view>
			<view style="font-size: 0.7em;text-align: right;" v-if="item.shouxufei > 0">手续费-{{ item.shouxufei }}元</view>
			<view style="font-size: 0.7em;text-align: right;">交易内容：兑换了{{ item.money }}元</view>
			</view>
			<view class="red" v-else="">{{ item.money }}元</view>
		</view>
		<!-- 没有记录 -->
		<view class="d-c-c p30" v-if="tableData.length == 0 && !loading">
			<text class="iconfont icon-wushuju"></text>
			<text class="cont">亲，暂无相关记录哦</text>
		</view>
		<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
	</view>
</template>

<script>
	
	
	import uniLoadMore from '@/components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				sousuondie:"",
				sousuolei:'',
				/*是否加载完成*/
				loading: true,
				/*顶部刷新*/
				topRefresh: false,
				/*手机高度*/
				phoneHeight: 0,
				/*可滚动视图区域高度*/
				scrollviewHigh: 0,
				/*数据列表*/
				tableData: [],
				/*最后一页码数*/
				last_page: 0,
				/*当前页面*/
				page: 1,
				/*每页条数*/
				list_rows: 20,
				no_more: false,
				type: 'all'
			};
		}, shijashew(e) {
     var date = new Date(timestamp);//时间d戳为10位需*1000，时间戳为13位的话不需乘1000
        let Y = date.getFullYear(),
            M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1),
            D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()),
            h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()),
            m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()),
            s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
        return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s
  },
		computed: {
			/*加载中状态*/
			loadingType() {
				if (this.loading) {
					return 1;
				} else {
					if (this.tableData.length != 0 && this.no_more) {
						return 2;
					} else {
						return 0;
					}
				}
			}
		},
		onLoad(e) {
			this.type = e.type;
			/*获取数据*/
			this.getData();
		},
		onReachBottom() {
			let self = this;
			if (self.page < self.last_page) {
				self.page++;
				self.getData();
			}
			self.no_more = true;
		},
		methods: {
			/*获取数据*/
			getData() {
				let self = this;
				let page = self.page;
				let list_rows = self.list_rows;
				self.loading = true;
				self.tableData =[];
				
				self._get(
					'user.User/orderjuka_list', {
						page: page || 1,
						list_rows: list_rows,
						type: self.type,
						sousuondie:self.sousuondie,
						sousuolei:self.sousuolei
					},
					function(data) {
						self.tableData = self.tableData.concat(data.data.list);
						self.last_page = data.data.list.last_page;
						if (data.data.list.last_page <= 1) {
							self.no_more = true;
							return false;
						}
						self.loading = false;
					}
				);
			},sousadje(){
				
					let self = this;
					if(!self.sousuondie){
						uni.showToast({
							title: '请输入搜素内容~',
							duration: 2000,
							icon: 'none'
						});
						return;
						
					}
					uni.showActionSheet({
						itemList: ['订单号', '俊卡号', '俊卡密'],
						success: function (res) {
							if(res.tapIndex >=0){
							self.sousuolei=res.tapIndex;
							self.getData();
							}
						},
						fail: function (res) {
							console.log(res.errMsg);
						}
					});
					
				
			}, onKeyInput: function(event) { 
				
				let self = this;
				
				if(self.sousuondie==null || event.target.value== null  || event.target.value== ''  || event.target.value== ""){
					
					self.sousuolei='';
					self.sousuondie='';
					self.getData();
				}
        },countDownddedd(timestamp) {
				
				if(timestamp){
				 var date = new Date(timestamp*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				    let Y = date.getFullYear(),
				        M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1),
				        D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()),
				        h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()),
				        m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()),
				        s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
				    return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s
					}
			},
		}
	};
</script>

<style></style>
